
import 'package:flutter_book/data/model/book_model.dart';
import 'package:flutter_book/data/model/yck/yck_rule_book_3_model.dart';
import 'package:flutter_book/route/route_config.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';

class AppRouter{


  static toTestPage() {
    Get.toNamed(RouteConfig.testPage);
  }

  //去二维码扫描界面
  static toScanQRCodePage<T>(Function(T) callBackValueListener){
    Permission.camera.request().then((value) {
      if (value.isGranted) {
        Get.toNamed(RouteConfig.scanQRCodePage)?.then((value){
          if(value!=null){
            callBackValueListener(value);
          }
        });
      }
    });
  }

  static toSourceAnalyzePage(YckRuleBook3Model model) {
    Get.toNamed(RouteConfig.sourceAnalyzePage, arguments: model);
  }

  static toBackstageHome() {
    Get.toNamed(RouteConfig.backstageHome);
  }

  static toAddSourcePage() {
    Get.toNamed(RouteConfig.addSourcePage);
  }

  static toResourcesDescriptionPage() {
    Get.toNamed(RouteConfig.resourcesDescriptionPage);
  }


  static toFeedWebViewPage() {
    Get.toNamed(RouteConfig.feedWebViewPage);
  }

  static toYckSourceListPage() {
    Get.toNamed(RouteConfig.yckSourceListPage);
  }

  static toSearchBookPage() {
    Get.toNamed(RouteConfig.searchBookPage);
  }

  static toBookDetailPage(BookModel bookModel) {
    Get.toNamed(RouteConfig.bookDetailPage,arguments: bookModel);
  }

  static toBookPage(BookModel bookModel) {
    Get.toNamed(RouteConfig.bookPage,arguments: bookModel);
  }

}